/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.ms.usercenter.model.entity;

import cn.hallele.mc.sdk.usercenter.common.enums.SexEnum;
import cn.hallele.mc.sdk.usercenter.common.enums.UserStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import lombok.*;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

/**
 * hallele_ms_usercenter
 *
 * @author anle5
 * @since 2024/10/5 14:18
 */
@Getter
@Setter
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "uc_user")
public class UserEntity implements Serializable {
    @Serial
    private static final long serialVersionUID = -7782177000991556327L;

    /**
     * 身份唯一标识
     * 生成策略: 从表key_generator中读取
     * name: TableGenerator唯一标识
     * pkColumnName：生成策略所对应键值的名称
     * pkColumnValue：键当前所生成的值，它的值将会随着每次创建累加
     * initialValue: 初始值
     * allocationSize: 递增至
     */
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "UserEntity")
    @TableGenerator(name = "UserEntity",
            table = "key_generator",
            pkColumnName = "gen_name",
            valueColumnName = "gen_value",
            pkColumnValue = "uc_user",
            initialValue = 1,
            allocationSize = 1
    )
    @Schema(name = "id")
    private Long id;

    /**
     * 租户id
     */
    @Schema(name = "tenant_id")
    private Integer tenantId;

    /**
     * 用户名
     */
    @Schema(name = "username")
    private String username;

    /**
     * 密码
     */
    @Schema(name = "password")
    private String password;

    /**
     * 头像地址
     */
    @Schema(name = "avatar_id")
    private Long avatarId;

    /**
     * 电话号码
     */
    @Schema(name = "phone_number")
    private String phoneNumber;

    /**
     * 邮箱
     */
    @Schema(name = "email")
    private String email;

    /**
     * 性别
     */
    @Schema(name = "sex")
    private SexEnum sex;

    /**
     * 年龄
     */
    @Schema(name = "age")
    private Integer age;

    /**
     * 用户状态
     */
    @Schema(name = "status")
    private UserStatusEnum status;

    /**
     * 个性签名
     */
    @Schema(name = "personality_signature")
    private String personalitySignature;

    /**
     * 密码过期时间
     */
    @Schema(name = "pass_expired_time")
    private Date passExpiredTime;

    /**
     * 账户过期时间
     */
    @Schema(name = "account_expired_time")
    private Date accountExpiredTime;

    /**
     * 创建时间
     */
    @Schema(name = "create_time")
    private Date createTime;

    /**
     * 最近更新时间
     */
    @Schema(name = "update_time")
    private Date updateTime;

    /**
     * 创建用户
     */
    @Schema(name = "create_by")
    private Long createBy;

    /**
     * 更新用户
     */
    @Schema(name = "update_by")
    private Long updateBy;
}
